import { Component, OnInit } from '@angular/core';
import { ApiService } from './../../../../core/api/api.service';
import { MessageService } from './../../../../core/service/message.service';

@Component({
    templateUrl: './auditedList.html',
    styles: [
        `
        `
      ]
})
export class PrescriptionAuditedComponent implements OnInit {
    page = {pageNo: 1};
    departmentList = [];
    isVisible = false;
    editTable = false;
    tabLoading = false;
    selectedRowData: any = {};
    medicineList = [];
    statusType = {
        'HOSPITAL_AUDIT': '等待药师审核',
        'HOSPITAL_REFUSE': '审核未通过',
        'HOSPITAL_APPROVE': '选择取药药店',
        'PHARMACY_AUDIT': '药店药师审核',
        'PHARMACY_REFUSE': '药店审核未通过',
        'PHARMACY_APPROVE': '前往药店取药',
        'COMPLETE': '已取药',
    };
    constructor(
        private apiService: ApiService,
        private msg: MessageService
        ) {
    }
    ngOnInit() {
        this.msg.setTitle('已审核处方');
        this.loadList();
    }
    loadList() {
        this.tabLoading = true;
        this.apiService.post('已审核处方列表(医院药师)', {...this.page}).then((res: any) => {
            this.tabLoading = false;
            this.departmentList = res.data.list;
        });
    }
    selectedRow(data){
        this.selectedRowData = data;
        this.tabLoading = true;
        this.apiService.post('处方审核详情(医院药师)', {id: data.id}).then((res: any) => {
            this.selectedRowData = res.data.prescription;
            this.medicineList = res.data.medicineList;
            this.tabLoading = false;
        });
    }
}
